package com.dkd.flow.emums;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.annotation.IEnum;
import com.fasterxml.jackson.annotation.JsonValue;

import java.util.Arrays;
/**
 * 流程状态 1:处理中 2:拒绝 3:完成
 */
public enum FlowStatus implements IEnum<Integer> {

    PROCESSING(1, "处理中"),
    REJECT_AND_END(2, "拒绝并结束"),
    DELETE(-1, "删除"),
    COMPLETE(3, "完成"),
    CANCEL(4, "取消"),
    RETURNED(5, "驳回"),
    RETURNED_ALL(6, "驳回所有"),
    DRAFT(0, "草稿");
    @EnumValue
    private final Integer value;
    private final String name;
    FlowStatus(Integer value, String name) {
        this.value = value;
        this.name = name;
    }
    @Override
    @JsonValue
    public Integer getValue() {
        return value;
    }
    public String getName() {
        return name;
    }
    public static String getName(Integer value) {
        return Arrays.stream(FlowStatus.values())
                .filter(o -> o.getValue()
                        .equals(value))
                .findFirst()
                .orElse(DELETE)
                .getName();
    }
    public static FlowStatus getFlowStatusByValue(Integer value) {
        return Arrays.stream(FlowStatus.values())
                .filter(o -> o.getValue()
                        .equals(value))
                .findFirst()
                .orElse(DELETE);
    }

}
